﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class DengLu : System.Web.UI.Page
{
//    private static string sqlconn = System.Configuration.ConfigurationManager.AppSettings["strConn"].ToString().Trim();
    protected void Page_Load(object sender, EventArgs e)
    {
       // lblMsg.Visible = false;
        txtid.Focus();
    }



    protected void btnJC_Click(object sender, EventArgs e)
    {
        string id = txtid.Text.ToString().Trim();
        users us = new users();
        us.p_id = id;
        int result = us.isExist(us);
       /* if (result >0)
        {
                lblMsg.Visible = true;
                lblMsg.Text = "此账号不可用！";
            }
            else
            {
                lblMsg.Visible = true;
                lblMsg.Text = "此账号可用！";

            }*/
    }

//        string sql = "select count(*)from parent where (ID='" + id + "')";
//        SqlConnection conn = new SqlConnection(sqlconn);
        //try
        //{
        //    conn.Open();
        //    SqlCommand comm = new SqlCommand(sql, conn);
        //    int result = (int)comm.ExecuteScalar();
        //    if (result > 0)
        //    {
        //        lblMsg.Visible = true;
        //        lblMsg.Text = "此账号不可用！";
        //    }
        //    else
        //    {
        //        lblMsg.Visible = true;
        //        lblMsg.Text = "此账号可用！";

        //    }
        //}
        //catch
        //{

        //}
    protected void btnZC_Click(object sender, EventArgs e)
{
     Response.Redirect("~/ZhuCe.aspx"); 
}

    protected void btnDL_Click(object sender, EventArgs e)
    {
        string id = txtid.Text.Trim();
        string ps = txtpassword.Text.Trim();
        users us = new users();
        us.m_id = id;
        us.m_password  = ps;
        int result1 = us.login1(us);//管理员
        int result2 = us.login(us);//家长
        if(result1==1)
        {
            Session["man_m_id"] = id ;
            Response.Redirect("~/manager.aspx");
        }
        else  if(result2==1)
        {
            
            Session["man_m_id"] = id;
            Response.Redirect("~/student.aspx");
        }
        else
        {
            Response.Write("<script>alert(\"对不起，您输入的用户不存在！\")</script>");
        }
    }
    protected void btnCZ_Click(object sender, EventArgs e)
{
        txtid.Text = "";
        txtpassword.Text = "";
}
}

